﻿using Styx;
using Styx.Plugins;
using Styx.WoWInternals;
using System;
using System.Diagnostics;
using Styx.WoWInternals.WoWObjects;

namespace Releaser
{
    class Releaser : HBPlugin
    {
        public override string Name { get { return "Releaser"; } }
        public override string Author { get { return "Leon Lin"; } }
        public override bool WantButton { get { return true; } }
        public override Version Version { get { return new Version(1, 0, 0, 0); } }

        private static LocalPlayer Me { get { return StyxWoW.Me; } }
        private static readonly Stopwatch Stopwatch = new Stopwatch();
        private readonly Random _random = new Random();
        public override void Pulse()
        {
            if (Me.IsDead)
            {
                if (!Stopwatch.IsRunning)
                {
                    Stopwatch.Start();
                }

                var rnd = _random.Next(2000, 6000);
                if (Stopwatch.ElapsedMilliseconds > rnd)
                {
                    Lua.DoString(string.Format("RunMacroText(\"{0}\")", "/script RepopMe()")); 
                    Stopwatch.Stop();
                }
            }
        }
    }
}

